class Friend {
  final int uid;       // 用户 ID
  late String notes;  // 备注（或昵称）
  late String avator; // 头像 URL

  Friend({
    required this.uid,
    required this.notes,
    required this.avator,
  });

  factory Friend.fromJson(Map<String, dynamic> json) {
    return Friend(
      uid: json['uid'] is int
          ? json['uid']
          : int.tryParse(json['uid']?.toString() ?? '') ?? 0,
      notes: json['notes']?.toString() ?? '',
      avator: json['avator']?.toString() ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'uid': uid,
      'notes': notes,
      'avator': avator,
    };
  }
}
